# -*- coding = utf-8 -*-
# name   : 表配置
# Author : admin
# Email  : 
# File   : table_name.py
# Ver    : 1.0
# Time   : 2025-07-15 10:34

from utils.operate_mongodb import OperateMongodb
from config import MONGODB_CONF, MONGODB_CONF_GYCC, MONGODB_CONF_WG

# 跑批大屏配置项目-数据库连接
mongo_obj_paopi = OperateMongodb(MONGODB_CONF)
_, db_mongo_paopi = mongo_obj_paopi.conn_mongodb()

# 桂银查查配置项目-数据库连接
mongo_obj_gycc = OperateMongodb(MONGODB_CONF_GYCC)
_, db_mongo_gycc = mongo_obj_gycc.conn_mongodb()

# 外管配置项目-数据库连接
mongo_obj_wg = OperateMongodb(MONGODB_CONF_WG)
_, db_mongo_wg = mongo_obj_wg.conn_mongodb()

# 跑批大屏配置项目- 表配置
paopi_table_names = [
    ("data_plat_system_monitor_job", 900, "create_date"),  # data_plat_system_monitor_job
    ("error0601", 365, "create_time"),
    ("error_info", 365, "create_time"),
    ("joblog", 365, "create_time"),
    ("lyj_esb_res", 7, "create_time"),
]

# 桂银查查配置项目
gycc_table_names = [
    ("data_lake_event_log", 7, "create_date"),  # data_lake_event_log
    ("data_lake_screen", 7, "create_date")  # data_lake_screen
]

# 外管配置项目
wg_table_names = [
    ("data_lake_event_log", 7, "create_date"),  # data_lake_event_log
    ("data_lake_screen", 7, "create_date")  # data_lake_screen
]

# 混合删除配置项目
delete_conf = {
    "paopi": {
        "name": "跑批大屏",
        "mongo_obj": mongo_obj_paopi,
        "db_mongo": db_mongo_paopi,
        "table_names": paopi_table_names,
        "status": True,
        "one_day": True
    },
    "gycc": {
        "name": "桂银查查",
        "mongo_obj": mongo_obj_gycc,
        "db_mongo": db_mongo_gycc,
        "table_names": gycc_table_names,
        "status": True,
    },
    "wg": {
        "name": "外管",
        "mongo_obj": mongo_obj_wg,
        "db_mongo": db_mongo_wg,
        "table_names": wg_table_names,
        "status": True,
    }
}

if __name__ == '__main__':

    for key, value in delete_conf.items():
        task_code = key
        task_name = value.get("name")
        mongo_obj = value.get("mongo_obj")
        db_mongo = value.get("db_mongo")
        table_names = value.get("table_names")
        status = value.get("status", False)
        if not status:
            continue

        for table_name, days, date_lie in table_names:
            temp_dict = {
                'db_mongo': db_mongo,
                'collection_name': table_name,
                'days': days,
                'date_lie': date_lie,
                'name': task_name,
                'one_day': value.get("one_day", False)
            }
            print(temp_dict)
